package cn.school.thoughtworks.section1;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

public class PracticeA {
    List<String> collectSameElements(List<String> collection1, List<String> collection2) {
        //实现练习要求，并改写该行代码。
        /*return (List<String>) collection1.stream().filter(item-> collection1.retainAll(collection2));*/

        Collection collection = new ArrayList(collection1);
        collection.retainAll(collection2);
        return (List<String>) collection;
    }
}
